from django.db import models
from ckeditor_uploader.fields import RichTextUploadingField


# Create your models here.


class User(models.Model):
    """ 用户表 """
    name = models.CharField(verbose_name="名称", max_length=32)
    password = models.CharField(verbose_name="密码", max_length=64)


class NoteBook(models.Model):
    """ 笔记本表 """
    title = models.CharField(verbose_name="标题", max_length=32)
    user = models.ForeignKey(verbose_name="用户", to="User", to_field="id", on_delete=models.CASCADE)
    create_time = models.DateTimeField(verbose_name="创建时间")


class Tag(models.Model):
    """ 标签表 """
    tag = models.CharField(verbose_name="标签", max_length=32)


class Note(models.Model):
    """ 笔记表 """
    title = models.CharField(verbose_name="标题", max_length=32)
    content = RichTextUploadingField(null=True, blank=True)
    notebook = models.ForeignKey(verbose_name="笔记", to="NoteBook", to_field="id", on_delete=models.CASCADE)
    tag = models.ManyToManyField(verbose_name="标签",null=True, to=Tag)
    create_time = models.DateTimeField(verbose_name="创建时间", null=True, blank=True)
